• Check command pod_volume is used to check percentage of available space in Kubernetes Pods.
• Spec - pod_volume check command has the following variables:
-> volumeName - Name of volume whose usage stats will be checked
-> secretName - Name of Kubernetes Secret used to pass hostfacts auth info
-> warning - Warning level value (usage percentage defaults to 80.0)
-> critical - Critical level value (usage percentage defaults to 95.0)
• Execution of this command can result in following states:
-> OK
-> WARNING
-> CRITICAL
-> UNKNOWN

# Tutorial
• you need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster.

kubectl create namespace demo

kubectl get namespaces
NAME          STATUS    AGE
default       Active    6h
kube-public   Active    6h
kube-system   Active    6h
demo          Active    4m

# Check volume of pods with matching labels
• If a PodAlert will be used check volume stats of pods with matching labels by setting spec.selector field.

cat ./docs/examples/pod-alerts/pod_volume/demo-0.yaml

apiVersion: monitoring.appscode.com/v1alpha1
kind: PodAlert
metadata:
  name: pod-volume-demo-0
  namespace: demo
spec:
  selector:
    matchLabels:
      app: nginx
  check: pod_volume
  vars:
    volumeName: www
    warning: '70'
    critical: '95'
  checkInterval: 5m
  alertInterval: 3m
  notifierSecretName: notifier-config
  receivers:
  - notifier: Mailgun
    state: CRITICAL
    to: ["ops@example.com"]
    
kubectl apply -f ./docs/examples/pod-alerts/pod_volume/demo-0.yaml

kubectl get pods -n demo

kubectl describe podalert -n demo pod-volume-demo-0

# Check volume stats of a specific pod
• If a PodAlert will be used check volume stats of a pod by name by setting spec.podName field.

cat ./docs/examples/pod-alerts/pod_volume/demo-1.yaml

apiVersion: monitoring.appscode.com/v1alpha1
kind: PodAlert
metadata:
  name: pod-volume-demo-1
  namespace: demo
spec:
  podName: busybox
  check: pod_volume
  vars:
    volumeName: mypd
    warning: '70'
    critical: '95'
  checkInterval: 5m
  alertInterval: 3m
  notifierSecretName: notifier-config
  receivers:
  - notifier: Mailgun
    state: CRITICAL
    to: ["ops@example.com"]
    
kubectl apply -f ./docs/examples/pod-alerts/pod_volume/demo-1.yaml

kubectl describe podalert -n demo pod-volume-demo-1

# Cleaning up
• To cleanup the Kubernetes resources

kubectl delete ns demo

# Link:- https://appscode.com/products/searchlight/5.1.1/guides/pod-alerts/pod_volume/